<template>
<div class="page">
  <navTop title="详情"></navTop>
  <div class="detail">
    <div class="chain_top">
      <div class="chain_top_img">
        <div class="chain_img">
          <img src="~@/assets/img/chain/chain.png" alt="">
        </div>
        <div class="chain_top_title">
          <div class="chain_name">{{ chain.chain_name }}</div>
          <div class="chain_compnay_number">企业：{{ chain.company_num }}个</div>
        </div>
      </div>
      <div class="chain_desc">
        <span>简介：</span>
        {{ detail.desc }}
        <!-- <div class="icon">
          <img src="~@/assets/img/chain/down.png">
        </div> -->
      </div>
    </div>
    <div class="chain_chart">
      <div class="chart" v-for="item,index in chain.children">
        <div v-if="index !==0"  class="chart_title blue" >{{ item.chain_name }}</div>
        <div v-if="index ===0"  class="chart_title" >{{ item.chain_name }}</div>
        <div class="des">
          <div class="des_item" v-for="i,k in item.children">{{ i.chain_name }}</div>
        </div>
      </div>
      <!-- <div class="chart">
        <div class="chart_title blue">中游</div>
        <div class="des">
          <div class="des_item">钙离子电池</div>
          <div class="des_item">电化学储能</div>
          <div class="des_item">压缩空气储能</div>
          <div class="des_item">氢能电池</div>
          <div class="des_item">氢能装备</div>
          <div class="des_item">抽水蓄能</div>
          <div class="des_item">光伏逆变器</div>
          <div class="des_item">钙钛矿电池</div>
          <div class="des_item">锂电池电解液</div>
        </div>
      </div>
      <div class="chart">
        <div class="chart_title blue">下游</div>
        <div class="des">
          <div class="des_item">钙离子电池</div>
          <div class="des_item">电化学储能</div>
          <div class="des_item">压缩空气储能</div>
          <div class="des_item">氢能电池</div>
          <div class="des_item">氢能装备</div>
          <div class="des_item">抽水蓄能</div>
          <div class="des_item">光伏逆变器</div>
          <div class="des_item">钙钛矿电池</div>
          <div class="des_item">锂电池电解液</div>
        </div>
      </div> -->
    </div>
    <div class="chain_tab">
      <div class="title">
        <div v-if="type === 1" class="tab_title a">
          龙头企业
        </div>
        <div v-if="type === 2" class="tab_title" @click=changeTitle(1)>
          龙头企业
        </div>
        <div v-if="type === 2" class="tab_title a">
          招商载体
        </div> 
        <div v-if="type === 1" class="tab_title" @click=changeTitle(2)>
          招商载体
        </div>
      </div>
    </div>
    <div class="box_div">
      <van-list
      v-model="isLoad"
      :finished="isfinish"
      finished-text="没有更多了"
      @load="getMore"
    >
      <template v-if="type === 1">
        <companyList :list="list"></companyList>
      </template>
      <template v-if="type === 2">
      <div class="park_list">
        <div class="item_list_div" v-for="item,index in park" @click="toPark(item.id)">
          <div class="item_list_img_div">
            <img class="item_list_img" v-if="item.thumb !== null" :src="item.thumb" />
            <img class="item_list_img" v-if="item.thumb === null" src="../assets/img/park.png" />
          </div>
          <div class="item_list_title">{{ item.park_name }}</div>
          <!-- <div class="item_list_desc text_line">
            位于新会区古井镇，前身为古井临港工业园，规划面积...
          </div> -->
        </div>
        <!-- <div class="item_list_div">
          <div class="item_list_img_div">
            <img class="item_list_img" src="https://guizhou-oss.oss-cn-guiyang-gzdata-d01-a.res.gzdata.com.cn/xj/37593f078661c5c6346d34014fe8120.png" />
          </div>
          <div class="item_list_title">新会智造产业园</div>
          <div class="item_list_desc text_line">
            位于新会区古井镇，前身为古井临港工业园，规划面积...
          </div>
        </div>
        <div class="item_list_div">
          <div class="item_list_img_div">
            <img class="item_list_img" src="https://guizhou-oss.oss-cn-guiyang-gzdata-d01-a.res.gzdata.com.cn/xj/37593f078661c5c6346d34014fe8120.png" />
          </div>
          <div class="item_list_title">新会智造产业园</div>
          <div class="item_list_desc text_line">
            位于新会区古井镇，前身为古井临港工业园，规划面积...
          </div>
        </div>
        <div class="item_list_div">
          <div class="item_list_img_div">
            <img class="item_list_img" src="https://guizhou-oss.oss-cn-guiyang-gzdata-d01-a.res.gzdata.com.cn/xj/37593f078661c5c6346d34014fe8120.png" />
          </div>
          <div class="item_list_title">新会智造产业园</div>
          <div class="item_list_desc text_line">
            位于新会区古井镇，前身为古井临港工业园，规划面积...
          </div>
        </div>
        <div class="item_list_div">
          <div class="item_list_img_div">
            <img class="item_list_img" src="https://guizhou-oss.oss-cn-guiyang-gzdata-d01-a.res.gzdata.com.cn/xj/37593f078661c5c6346d34014fe8120.png" />
          </div>
          <div class="item_list_title">新会智造产业园</div>
          <div class="item_list_desc text_line">
            位于新会区古井镇，前身为古井临港工业园，规划面积...
          </div>
        </div>
        <div class="item_list_div">
          <div class="item_list_img_div">
            <img class="item_list_img" src="https://guizhou-oss.oss-cn-guiyang-gzdata-d01-a.res.gzdata.com.cn/xj/37593f078661c5c6346d34014fe8120.png" />
          </div>
          <div class="item_list_title">新会智造产业园</div>
          <div class="item_list_desc text_line">
            位于新会区古井镇，前身为古井临港工业园，规划面积...
          </div>
        </div> -->
      </div>
        
      </template>
    </van-list>
    </div>
  </div>
</div>
</template>
<script>
import companyList from '@/components/ssList/companyList.vue'
import navTop from '@/components/navTop.vue'
import { company,chain,park } from '@/api/api.js'
export default {
  data() {
    return {
      list:[],
      park:[],
      detail:{},
      companyTotal:[],
      total: 0,
      type:1,
      page: 1,
      id: 0,
      isfinish: false,
      isLoad: true,
      chain:{}
    }
  },
  components: {
    navTop,
    companyList
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      this.page = 1
      this.isfinish = false
      this.isLoad = true
      this.id = this.$route.query.id
      this.list = []
      this.park = []
      this.companyTotal = []
      this.chian = {}
      this.detail = {}
      this.getList()
      this.getChainInfo()
      this.getParkList()
      this.getDetail()
      this.getCompanyTotal()
    },
    changeTitle(type) {
      this.type = type
      this.init()
    },
    getDetail(){
      let data = {
        id: this.id,
      }
      chain.getChainDetail({...data}).then(res => {
        this.detail = res.data
      })
    },
    getCompanyTotal() {
    },
    getMore() {
      if (this.isfinish||this.list.length==0) {
        return
      }
      this.page++
      this.getList()
    },
    getParkList(){
      let data = {
        page: this.page,
        chain_id:this.id,
        city_id:2380,
      }
      park.getList({...data}).then(res => {
        this.park = res.data.data
      })
    },
    getChainInfo() {
      let data = {
        id: this.id,
        company_num_fag:1,
        city_id:2380
      }
      chain.getChainInfo({...data}).then(res => {
        this.chain = res.data[0]
      })
    },
    toPark(id) {
      this.$router.push({
        path: '/parkDetail',
        query: {
          id: id,
          chain_id: this.id
        }
      })
    },
    getList() {
      let data = {
        page: this.page,
        chain_id:this.id,
        label_id:50150,
        city_id:2380,
        ...this.query
      }
      company.getList({...data}).then(res => {
        this.isLoad = false
        this.list.push(...res.data.data)
        this.total = res.data.total
        if (this.list.length >= this.total) {
          this.isfinish = true
        }
      })
    },
  }
}
</script>
<style lang="scss" scoped>
.detail{
  width: calc(100% - 10px);
  height: 100%;
  padding: 5px;
  background-color: #F7F7F7;
  .chain_top{
    width: 100%;
    height: auto;
    background-color: #fff;
    .chain_top_img {
      display: flex;
      width: 100%;
      padding:20px 10px 0 10px;
      .chain_img{
        img {
          width: 50px;
          height: 50px;
        }
      }
      .chain_top_title{
        margin-left: 10px;
       .chain_name{
          font-size: 16px;
          font-weight: 600;
        }
       .chain_compnay_number{
          font-size: 11px;
          margin-top: 2px;
          padding:2px 10px;
          background: rgba(250,138,38,0.1);
          color: #FA8A26;
        }
      }
    }
    .chain_desc{
      width: calc(100% - 20px);
      padding: 0 10px 10px 10px;
      color:#555;
      font-family: PingFang-SC-Regular;
      font-size: 14px;
      span {
        color: #999;
      }
      .icon{
        text-align: center;
        margin-top: 10px;
        img {
          width: 15px;
          height: 15px;
        }
      }
    }
  }
  .chain_tab {
    width: calc(100% - 20px);
    height: auto;
    background-color: #fff;
    margin-top: 10px;
    padding: 10px;
    border-radius: 3px 3px 3px 3px;
    .title {
      display: flex;
      flex-wrap: wrap;
      font-size: 16px;
      .tab_title{
        width: 20%;
        padding: 5px 10px;
        text-align: center;
        font-family: PingFang-SC-Regular;
      }
      .a {
        border-bottom: 6px solid #FA8A26;
        border-bottom-left-radius: 3px;
        border-bottom-right-radius: 3px;
        font-family: PingFang-SC-Bold;
        font-weight: 600;
      }
    }
  }
  .box_div{
    // margin: 0 10px 10px;
    // padding: 10px;
    // background: #FFFFFF;
    // box-shadow: 0px 3px 9px 2px rgba(250,135,30,0.13);
    // border-radius: 4px 4px 4px 4px;
    height: calc(100% - 115px);
    overflow: auto;
    .item_div{
      background: #FFFFFF;
      box-shadow: 0px 3px 9px 2px rgba(68,142,238,0.13);
      border-radius: 4px;
      margin-bottom: 10px;
      overflow: hidden;
      position: relative;
      margin: 10px 5px;
      .item_img_div{
        width: 100%;
        position: relative;
        .item_img{
          width: 100%;
          display: block;
          height: auto !important;
        }
      }
      .item_title{
        font-size: 14px;
        color: #333333;
        width: calc(100% - 20px);
        margin: 10px 10px 5px 10px;
      }
      .item_desc{
        width: calc(100% - 20px);
        font-size: 10px;
        color: #999999;
        margin: 0px 10px 10px 10px;
      }
    }
    .park_list {
      display: flex;
      flex-wrap: wrap;
      .item_list_div{
        background: #FFFFFF;
        border-radius: 4px;
        margin-bottom: 10px;
        width: calc(50% - 10px);
        overflow: hidden;
        position: relative;
        margin: 10px 5px;
        .item_list_img_div{
          width: 100%;
          position: relative;
          .item_list_img{
            width: 100%;
            display: block;
            height: auto !important;
          }
        }
        .item_list_title{
          font-size: 14px;
          color: #333333;
          width: calc(100% - 20px);
          margin: 10px 10px 5px 10px;
        }
        .item_list_desc{
          width: calc(100% - 20px);
          font-size: 10px;
          color: #999999;
          margin: 0px 10px 10px 10px;

        }
      }
    }
    

  }
  .chain_chart{
    width: calc(100% - 20px);
    height: auto;
    background-color: #fff;
    margin-top: 10px;
    padding: 10px;
    border-radius: 3px 3px 3px 3px;
    .chart{
      width: 100%;
      margin-top:10px;
      background: rgba(21,134,255,0.05);
      .chart_title{
        width: 100%;
        background-color: #FF7A7A;
        color:#fff;
        text-align: center;
        height: 35px;
        line-height: 35px;
        font-size: 15px;
        font-family: PingFang-SC-Medium;
        border-radius: 3px 3px 0px 0px;
      }
      .blue {
        background-color: #1586FF;
      }
      .des{
        width: calc(100% - 10px);
        display: flex;
        flex-wrap: wrap;
        padding: 5px 5px;
        .des_item{
          width: calc(33% - 9px);
          margin: 4px;
          height: 45px;
          line-height: 45px;
          text-align: center;
          color:#1885FE;
          border: #1885FE solid 1px;
          border-radius: 3px;
        }
      }
    }
  }
}
</style>